#pragma once

#include <sys/fcntl.h>
#include <iostream>

enum
{
    SOCKET_ERROR = 1,
    BIND_ERROR,
    LISTEN_ERROR,
    CONNECT_ERROR,
    RECV_ERROR,
    SEND_ERROR,
    EPOLL_CREATE_ERROR,
    EPOLL_WAIT_ERROR
};

void SetNoBlock(int fd)
{
    int fl = fcntl(fd, F_GETFL);
    if (fl < 0)
    {
        perror("fcntl");
        return;
    }

    fcntl(fd, F_SETFL, fl | O_NONBLOCK);
}